﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SSCMoreGamesAdapter  {
	private static string _methodSetGameObjectName = "setGameObjName";
	private static string _methodGetButtonImagePath = "getButtonImagePath";
	private static string _methodGetDefaultAppIconPath = "getDefaultAppIconPath";
	private static string _methodGetFirstAppIconPath = "getFirstAppIconPath";
	private static string _methodGetSmallButtonImagePath = "getSmallButtonImagePath";
	private static string _methodShow = "show";
	private static string _methodGetIconsPath = "getIconsPathForUntiy3D";
	private static string _methodRefresh = "init";


	private static SSCMoreGamesAdapter _instance;

	public static SSCMoreGamesAdapter getInstance(){
		if (_instance == null) {
			_instance = new SSCMoreGamesAdapter ();
		}
		return _instance;
	}

	public void setGameObjectName(string name){
		AndroidHelper.getMoregamesManagerAndroidObject ().Call (_methodSetGameObjectName, name);
	}

	public List<string> getIconsPath()
	{
		string ret =  AndroidHelper.getMoregamesManagerAndroidObject ().Call<string> (_methodGetIconsPath);
		if (ret != null && ret.Length > 0) {
			string[] strarr = ret.Split(',');
			List<string> list = new List<string>();
			foreach(string str in strarr)
			{
				if(str.Length > 0)
					list.Add(str);
			}

			return list;
		}
		return null;
	}

	public string getButtonImagePath() 
	{
		return AndroidHelper.getMoregamesManagerAndroidObject ().Call<string> (_methodGetButtonImagePath);
	}

	public string getDefaultAppIconPath() 
	{
		return AndroidHelper.getMoregamesManagerAndroidObject ().Call<string> (_methodGetDefaultAppIconPath);
	}

	public string getFirstAppIconPath() 
	{
		return AndroidHelper.getMoregamesManagerAndroidObject ().Call<string> (_methodGetFirstAppIconPath);
	}

	public string getSmallButtonImagePath() 
	{
		return AndroidHelper.getMoregamesManagerAndroidObject ().Call<string> (_methodGetSmallButtonImagePath);
	}

	public void refresh() 
	{
		AndroidHelper.getMoregamesManagerAndroidObject ().Call (_methodRefresh);
	}

	public void show(int animation = (int)MoreGameAnimationType.MGAT_EXPAND) 
	{
		 AndroidHelper.getMoregamesManagerAndroidObject ().Call (_methodShow,animation);
	}
}
